{extend name="public/layout" /}
{block name="title"}{$meetingInfo.meeting_name}签到{/block}
{block name="head"}
<link rel="stylesheet" href="/public/plugins/dropload/dropload.css">
{/block}
{block name="body"}
<div class="mcm-head" style="position:relative">
    <div class="head-left">
        <a href="{:url('index',['dept_id'=>$Request.param.dept_id])}" class="link">
            <span class="iconfont icon-zuoyou1"></span>
        </a>
    </div>
    <div class="head-title">
        {$meetingInfo.meeting_name}签到
    </div>
</div>
{$isJoin}
{switch name="is_join" }
{case value="0"}
您的企业不再此次会议的邀请列表，请联系管理员
<a href="{:url('info',['meeting_id'=>$meetingInfo['meeting_id']])}">点此返回会议详情</a>
{/case}
{case value="1"}
<a href="javascript:;" class="weui-btn weui-btn_primary" onclick="userlogin()">登陆</a>
{/case}
{case value="2"}
<div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">企业验证码</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="text" id="company_code" pattern="*" placeholder="企业验证码">
        </div>
    </div>
    <a href="javascript:;" class="weui-btn weui-btn_primary" onclick="meetingSign()">签到</a>
</div>
{/case}
{case value="3"}
您已签到
<a href="{:url('info',['meeting_id'=>$meetingInfo['meeting_id']])}">点此返回会议详情</a>
{/case}
{/switch}
{include file="public/footer"/}
{/block}
{block name="js"}
<script src="/public/plugins/template/template.js"></script>
<script type="text/html" id="login-tpl">
    <form id="loginForm">
        <input type="hidden" name="reback" value="http://b2b2c.local/circle/member/index.html">
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">手机号码</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="number" required="" name="member_mobile" placeholder="请输入手机号">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" required="" name="member_pass" placeholder="请输入密码">
                </div>
            </div>
        </div>
    </form>
</script>
<script type="text/html" id="reg-tpl">
    <form method="post" class="form-horizontal" id="regForm">
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">您的姓名</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" name="member_name" value="" placeholder="请输入您的姓名">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">手机号码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="tel" name="member_mobile" id="mobile" value="" placeholder="请输入手机号">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" name="member_pass" placeholder="请输入密码">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">确认密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" name="member_pass_ng" placeholder="请再次输入密码">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">短信验证</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="number" name="vcode" placeholder="请输入验证码">
                </div>
                <div class="weui-cell__ft">
                    <a class="weui-vcode-btn weui-btn_disabled" href="javascript:;" onclick="sendSms()">获取验证码</a>
                </div>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label">企业名称</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" name="company_name" onclick="getCompany(this)" placeholder="请输入企业名称">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label">职务</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" name="member_duties" id="member_duties" placeholder="请输入职务">
            </div>
        </div>
    </form>
</script>
<script>
    function userlogin() {
        var html=template('login-tpl',{});
        //页面层
        layer.open({
            type: 1
            ,content: html
            ,anim: 'up'
            ,btn: ['登陆', '去注册']
            ,yes:function () {
                var data=$('#loginForm').serialize();
                $.post('{:url("/circle/Public/userLogin")}',data,function (res) {
                    layer.open({
                        content: res.msg
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                    if(res.code){
                        window.location.reload();
                    }
                });
            }
            ,no:userReg
        });
    }
    function userReg() {
        var html=template('reg-tpl',{});
        //页面层
        layer.open({
            type: 1
            ,content: html
            ,anim: 'up'
            ,btn: ['注册', '去登陆']
            ,yes:function () {
                var data=$('#regForm').serialize();
                $.post('{:url("/circle/Public/userReg")}',data,function (res) {
                    layer.open({
                        content: res.msg
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                    if(res.code){
                        window.location.reload();
                    }
                });
            }
            ,no:userlogin
        });
    }
    function sendSms(){
        var mobile = $('#mobile').val();
        if(mobile == 'null'){
            alert('请先属入手机号');
        }else{
            $.post("{:url('/circle/Public/sendSms')}",{mobile: mobile},function(res){
                layer.open({
                    content: res.msg
                    ,skin: 'msg'
                    ,time: 2 //2秒后自动关闭
                });
            })
        }
    }
    function getCompany(obj) {
        var company_name=$(obj).val();
        $.post('{:url("isCompany")}',{'company_name':company_name},function (res) {
            if (!res.code){
                layer.open({
                    title:'企业名称未知'
                    ,content: '您的企业尚未在本平台注册,请检查是否正确，如果继续申请,我们的工作人员有可能联系您补全公司信息'
                    ,btn: '我知道了'
                });
            }
        })
    }
    function meetingSign() {
        var company_code=$('#company_code').val();
        $.post('{:url("meetingSign")}',{meeting_id:'{$meetingInfo.meeting_id}',company_code:company_code},function (res) {
            layer.open({
                content: res.msg
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            if (res.code){
                location.href='{:url("info",["meeting_id"=>$meetingInfo.meeting_id])}'
            }
        })
    }
</script>
{/block}